package cn.fl.ref.fncprjdrawmon.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.ref.fncprjdrawmon.service.IFncPrjDrawMonService;
import cn.fl.ref.fncprjdrawmon.transform.FncPrjDrawMonVOTransform;
import cn.fl.ref.fncprjdrawmon.vo.FncPrjDrawMonVO;
import fl.ref.fncprjdrawmon.condition.FncPrjDrawMonQueryCondition;
import fl.ref.fncprjdrawmon.dto.FncPrjDrawMonDTO;
import fl.ref.fncprjdrawmon.service.IFncPrjDrawMonApiService;
/**
 * @Description: 再融资项目到账明细表
 * @Description:业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 * 服务实现层
 */
@Service
public class FncPrjDrawMonServiceImpl implements IFncPrjDrawMonService {

	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory.getLogger(IFncPrjDrawMonService.class);
	
	@Autowired
	private IFncPrjDrawMonApiService  fncPrjDrawMonApiService;

	@Override
	public FncPrjDrawMonVO selectById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		FncPrjDrawMonDTO dto = this.fncPrjDrawMonApiService.selectById(id);
		return FncPrjDrawMonVOTransform.toVO(dto);
	}

	@Override
	public Long add(FncPrjDrawMonVO entity) throws BaseException {
		if(null == entity){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		//系统日志-有用户的情况下
		BaseLogUtils.info(logger, "add", "新增FncPrjDrawMon数据.", CurrentThreadContext.getCurrentUserName());
		
		//系统日志-无用户的情况下
		BaseLogUtils.info(logger, "add", "新增FncPrjDrawMon数据.");
		return this.fncPrjDrawMonApiService.add(FncPrjDrawMonVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		return this.fncPrjDrawMonApiService.removeById(id);
	}

	@Override
	public boolean modify(FncPrjDrawMonVO entity) throws BaseException {
		if(null == entity){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		return this.fncPrjDrawMonApiService.modify(FncPrjDrawMonVOTransform.toDTO(entity));
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException {
		if(null == page)page = new Pager();
		return this.fncPrjDrawMonApiService.searchListPage(page);
	}
	

	@Override
	public List<FncPrjDrawMonVO> searchList(FncPrjDrawMonQueryCondition condition) {
		// TODO Auto-generated method stub
		return FncPrjDrawMonVOTransform.toVOList(this.fncPrjDrawMonApiService.searchList(condition))  ;
	}	



}
